package demo02;
/*题目：计算字符串中子串出现的次数 */
public class topic49 {
    public static void main(String[] args) {
        int num = getMaches("abcabcabcabca","ca");
        System.out.println(num);
    }

    public static int getMaches(String str,String substr){
        int count = 0;
        for(int i=0;i<str.length()+1-substr.length();i++) {
            if(str.substring(i, substr.length()+i).equals(substr)) {
                count++;
            }
        }
        return count;
    }
}
